<template>
  <div class="p-card" @click="goPage(product)">
    <el-image
      style="width: 100%; height: 180px"
      :src="baseImgUrl + product.skuDefaultImg"
      fit="cover"
    ></el-image>
    <p class="p-desc">
      {{ product.skuName }}
    </p>
    <div class="p-footer">
      <div class="price">￥{{ product.price }}</div>
      <div class="salecount">销量: {{ product.saleCount }}</div>
    </div>
  </div>
</template>
<script setup>
import { useRouter } from "vue-router";
const router = useRouter();
const props = defineProps({
  product: {
    type: Object,
    default: {},
  },
});
const product = ref(props.product);
const baseImgUrl = import.meta.env.VITE_APP_BASE_API;
const goPage = (item) => {
  console.log(item);
  router.push({
    path: "/product",
    query: {
      spuId: item.spuId,
      skuId: item.skuId,
    },
  });
};
</script>
<style lang="scss" scoped>
.p-card {
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px 20px 10px 20px;
  transition: all 0.5s;
  margin-bottom: 20px;
  overflow: hidden;
  min-height: 293px;
  &:hover {
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1),
      0 4px 6px -4px rgb(0 0 0 / 0.1);
    transform: translateY(-10px);
  }

  .p-desc {
    width: 184px;
    text-wrap: wrap;
    margin-top: 10px;
    margin-bottom: 10px;
    // height: 40px;
    overflow: hidden;
    display: -webkit-box;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .p-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .price {
      color: rgb(185 28 28);
      font-weight: 600;
      font-size: 16px;
    }
    .salecount {
      font-size: 12px;
    }
  }
}
</style>
